<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="moduleList" />
<link rel="stylesheet" href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script src="${staticPath}/js/jquery-dialog.js" type="text/javascript"></script>
<script src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js" type="text/javascript"></script>
<script src="${staticPath}/js/jQuery.FillOptions.js"></script>
<script type="text/javascript">
$(document).ready( function() {
	// 选择地区
var contractType = $("#contractType").val();
	$("#queryBtn").click(function(){
		$("#"+contractType+"Form").find("input[name='pageNo']").each(function(){
			$(this).val(1);
		});
		alert('')
		$("#"+contractType+"Form").submit();
	});
	$("#clean").click(function(){
		$("#storeId").empty();
		$("#storeId").append("<option value='' >---请选择---</option>");
		$("#store").val("");
		$("#floorId").empty();
		$("#floorId").append("<option value='' >---请选择---</option>");
		$("#floor").val("");
	});
	
	var storeId1;
	var contextPath = Com_Parameter.ContextPath;
	var contractType = $("#contractType").val();
	var area = $("#area").val();
	var areaId = $("#areaId").val();
	if(area !="" && area!= null && areaId != "" && areaId !=null){
		$.get(contextPath + '/biz/contract/commonContract/'+ areaId + '/getStoreByAreaId', function(data) {
			var jsonObj = eval('(' + data + ')');
			for (var i = 0; i < jsonObj.length; i++) {
				var shop = jsonObj[i];
				$("#siteid").append("<option value='" + shop.code + "'>"+ shop.name + "</option>");
				$("#siteid").children("option").each(function() {
					if($(this).val() == storeId1){
						$(this).attr("selected","selected");
					}
				});
			}
		});
		$.get(contextPath + '/biz/contract/commonContract/'+ storeId1 + '/getFloorByStoreId', function(data) {
			var jsonObj = eval('(' + data + ')');
			for (var i = 0; i < jsonObj.length; i++) {
				var floor = jsonObj[i];
				$("#floorId").append("<option value='" + floor.code + "'>"+ floor.name + "</option>");
				$("#floorId").children("option").each(function() {
					if($(this).val() == floorId1){
						$(this).attr("selected","selected");
					}
				});
			}
		});
	}	
	var opt = {
		service : "selectOneRegionService",
		idField : "areaId",
		nameField : "areaName",
		title : "地区选择对话框"
	};
	$("#areaName").Dialog(opt);
	// 选取门店
	$("#areaName").blur(function() {
		var areaId = $("#areaId").val();
		if(areaId !="" && areaId !=null){
		$.get(contextPath + '/biz/contract/commonContract/'+ areaId + '/getStoreByAreaId', function(data) {
			var jsonObj = eval('(' + data + ')');
			$("#siteid").children("option").each(function() {
				$(this).remove();
			});
			$("#siteid").append("<option value=''>---请选择---</option>");
					for (var i = 0; i < jsonObj.length; i++) {
						var shop = jsonObj[i];
						$("#siteid").append("<option value='" + shop.code + "'>"+ shop.name + "</option>");
					}
				});
		}
	});
	// 选取楼层
	$("#siteid").change(function() {
			var storeId = $("#siteid").val();
			var store;
			$(this).children("option").each(function() {
				if ($(this).val() == storeId) {
					store = $(this).text();
				}
			});
			$("#site").val(store);
			if (storeId != "" && storeId != null) {
				$.get(contextPath + '/biz/contract/commonContract/'+ storeId + '/getFloorByStoreId', function(data) {
					var floorList = eval('(' + data + ')');
					$("#floor").children("option").each(function() {
						$(this).remove();
					});
					$("#floor").append("<option value=''>---请选择---</option>");
					for (var i = 0; i < floorList.length; i++) {
						var floor = floorList[i];
						$("#floor").append("<option value='" + floor.code+ "'>" + floor.name+ "</option>");
					}
				});
			}
	});
	$("#floor").change(function() {
		var floorId = $("#floor").val();
		var floor;
		$(this).children("option").each(function() {
			if ($(this).val() == floorId) {
				floor = $(this).text();
			}
		});
		$("#floorName").val(floor);
	});

	$("#serch").click(function() {
			$("#searchForm").attr("action","${contextPath}/biz/contract/" + contractType+ "/list");
	});
	$("#shopDialog").click(function(){
		var floorId=$("#floorId").attr("value");
		var storeId=$("#storeId").attr("value");
		if(floorId==null||floorId==''){
			$("#floor").focus();
			top.$.jBox.tip('楼层不能为空','warning');
			return false;
		}else{
			$("#modalBrand").load(contextpath+"/biz/contract/commonContract/showModal?floor="+floorId+"&siteid="+storeId,function(){
				
				 $("#modalBrand").modal("show");  
			}); 
		}
	});
	$("#storeId").change(function(){
		var store = $("#store").val();
		var storeId = $("#storeId").val();
	});
	
});


</script>
</head>
<body>
	<form:form action="${contextPath}/sys/base/berthmaindata/getList?navId=${navId}" id="berthMaindataForm" name="listForm" modelAttribute="berthMaindata" method="post" class="form-inline" role="form">
		<ol class="breadcrumb map_1">
			<li><a href="${contextPath}/index">首页</a></li>
			<li><a href="${contextPath}/biz/intent/intAssociated/list?navId=${navId}">招商合约</a></li>
			<li class="active">铺位列表</li>
		</ol>
		<input type="hidden" id="contractType" value="berthMaindata">
		<div class="o-l-search-builder f_1">
	         <div id="statement-search-builder" class="collapse" style="height:auto;">
	          
	             <div class="f_3">
	                 <div class="form-group col-sm-6">
	                      <label for="inputtext3" class="col-sm-3 control-label f_4">区域：</label>
	                       <div class="col-sm-9 f_6">
	                       	<div class="input-group">
	                       		<input type="hidden" id="areaId"  name="areaId" value="${associatedContract.areaId}"/> 
								<input type="text" class="f_5" id="areaName" readonly="readonly" name="areaName" value="${associatedContract.area}">
								<span class="input-group-addon f_time"><a id="clean" href="#"><i class="glyphicon glyphicon-remove"></i></a></span>
								
							</div>
						 </div>
	                  </div>
	                     <div class="form-group col-sm-6">
	                      <label for="store" class="col-sm-3 control-label f_4">门店名：</label>
	                      <div class="col-sm-9 f_6">
	                        <select type="text" class="f_5" id="siteid" name="siteid">
	                        	<option value="" >---请选择---</option>
	                        	<c:if test="${not empty associatedContract.storeId}">
	                        		<option value="${associatedContract.storeId}" selected="selected" >${associatedContract.store}</option>
	                        	</c:if>
	                        </select>
	                        <input type="hidden"  id="site" name="site" value="${associatedContract.store}"/>
	                      </div>
	                  </div>
	                
	             </div>
	             <div class="f_3">
	              
	                  <div class="form-group col-sm-6">
	                      <label for="floorId" class="col-sm-3 control-label f_7">楼层：</label>
	                      <div class="col-sm-9 f_6">
	                        <select  class="f_5" id="floor" name="floor">
	                        	<option value="">---请选择---</option>
	                        	<c:if test="${not empty associatedContract.floorId}">
	                        		<option value="${associatedContract.floorId}" selected="selected">${associatedContract.floor}</option>
	                        	</c:if>
	                        </select>
	                        <input type="hidden" id="floorName" name="floorName"/>
	                      </div>
	                  </div>
	                  
	                    <div class="form-group col-sm-6">
	                      <label for="contractAttribute" class="col-sm-3 control-label f_7">招商编号：</label>
	                      <div class="col-sm-9 f_6">
	                         	<input type="text" id="mechId" name="mechId" class="f_5">
	                      </div>
	                  </div>
	             </div>
	          
	         </div>
	       
	         <div class="o-l-chevron-down"><a href="#" class="btn btn-default collapsed" data-toggle="collapse" data-target="#statement-search-builder" id="chevronDownBtn" role="button"><span id="glyphiconspan" class="glyphicon glyphicon-chevron-down"></span></a>
	         </div>
	           <div class="f_8">
	              <div class="f_2">
	                  <div class="col-sm-4 f_6">
	                        <input  class="f_5" placeholder="铺位号" name="berthId"/>
	                  </div>
	                  <button type="button" id="queryBtn" class="btn btn-warning btn_1">查&nbsp&nbsp;询</button>
	             </div>
	         </div>
	     </div>
    	
		<tags:message content="${message}"/>
			<div class="o-l-search-builder f_9">
		<table class="table table-striped table-hover o-l-table" id="table1">
			<thead>
				<tr>
					<th style="width: 1px"><input type="checkbox" data-ckb="all"></th>
					<th>铺位号</th>
					<th>面积</th> 
					<th>门店</th>
					<th>楼层</th>
					<th>使用类型</th>
					<th>招商编号</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${page.list}" var="brethMaindata">
					<tr data-herf="${contextPath}/sys/base/berthmaindata/get?id=${brethMaindata.id}&navId=${navId}" data-target="_self">
						<td class="o-l-tab-ckb">
							<input type="checkbox" data-ckb-id="${brethMaindata.id}">
						</td>
						<td>${brethMaindata.berthId}</td>
						<td>${brethMaindata.area}</td>
						<td>${brethMaindata.baseShop.name}</td>
						<td>${brethMaindata.basefloor.name}</td>
						<td>${brethMaindata.snunr}</td>
						<td>${brethMaindata.mechId}</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		</div>
<pager:pager pageSize="${page.pageSize}" pageNo="${page.pageNo}" url="" total="${page.total}"/>
<script type="text/javascript" src="${staticPath}/js/list.js"></script>

</form:form>
<script type="text/javascript">
$('.form_date').datetimepicker({
    language:  'zh-CN',
    weekStart: 1,
    todayBtn:  1,
	autoclose: 1,
	todayHighlight: 1,
	startView: 2,
	minView: 2,
	forceParse: 0,
	format: 'yyyy-mm-dd'
});
</script>
</body>
</html>